home *** CD-ROM | disk | FTP | other *** search
- RCS_ID_C "$Id: misc.c,v 0.1 1993/03/29 07:49:34 ppessi Exp $";
- /* misc.c -- collection of generic useful functions used by niftyterm
- *
- * Copyright 1988, 1989 Chris Newman
- * All Rights Reserved
- * Permission is granted ot copy, modify, and use this as long
- * as this notice remains intact. This is a nifty program.
- *
- * $Author: ppessi $ $Revision: 0.1 $ $Date: 1993/03/29 07:49:34 $
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include "nifty.h"
- #include <devices/timer.h>
-
- extern int access(), execve();
- extern struct timerequest *tr;
-
- /* a string compare which ignores case
- */
- #define TOLOWER(c) (isupper(c) ? tolower(c) : c)
- int lstrncmp(str1, str2, len)
- register char *str1, *str2;
- register int len;
- {
- while (TOLOWER(*str1) == TOLOWER(*str2) && --len)
- str1++, str2++;
- return (TOLOWER(*str1) - TOLOWER(*str2));
- }
-
- /* This sleeps for a given amount of microseconds
- */
- void
- udelay(val)
- unsigned long val;
- {
- tr->tr_time.tv_secs = val / 1000000L;
- tr->tr_time.tv_micro = val % 1000000L;
- tr->tr_node.io_Command = TR_ADDREQUEST;
- DoIO((struct IORequest *)tr);
- }
-
- /* simple procedure to convert decimal number of
- * less than 20 digits to a string.
- */
- char *itos(i)
- int i;
- {
- static char sbuf[20];
- register char *pos = sbuf, *rpos = sbuf;
-
- while (i || pos == sbuf) {
- *pos++ = "0123456789"[i % 10];
- i /= 10;
- }
- *pos-- = '\0';
- while (pos > rpos) {
- register char temp = *pos;
- *pos-- = *rpos;
- *rpos++ = temp;
- }
-
- return (sbuf);
- }
-